package kalambury.srv;

import kalambury.db.UserEntity;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.PersistenceUnit;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: damienix
 * Date: 02.11.12
 * Time: 22:37
 * To change this template use File | Settings | File Templates.
 */
public class TomcatContextListener implements ServletContextListener {

    /**
     * inicjalizacja serwera
     * @param servletContextEvent tomcatowy kontekst
     */
    @Override
    public void contextInitialized(ServletContextEvent servletContextEvent) {

        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    ServerImpl.run();
                } catch (Exception e) {
                    e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
                }
            }
        }).start();

    }

    /**
     * destruktor serwera
     * @param servletContextEvent tomcatowy kontekst
     */
    @Override
    public void contextDestroyed(ServletContextEvent servletContextEvent) {

    }

}
